<?php
/**
 * Copyright (c) 2006, PORTALIER Julien
 * 
 * Licensed under The LGPL License
 * Redistributions of files must retain the above copyright notice.
 * 
 * @copyright    Copyright (c) 2006, Julien PORTALIER
 * @link         http://code.google.com/p/feather-cm
 * @license      http://www.opensource.org/licenses/lgpl-license.php The LGPL License
 * 
 * @deprecated
 */

class PaginationComponent
{
	protected $controller;
	
	function startup(Controller $controller)
	{
		$this->controller = $controller;
#		$this->controller->bindCallback('beforeRender', 'Pagination', 'paginate');
	}
	
	function getPage()
	{
		return isset($this->controller->params['url']['page']) ? $this->controller->params['url']['page'] : 1;
	}
	
	function paginate($link=null, $limit=null, $count=null)
	{
		$this->controller->set('paging', array(
			'limit' => empty($limit) ? $this->controller->limit : $limit,
			'count' => empty($count) ? $this->controller->{$this->controller->modelClass}->count : $count,
			'page'  => $this->getPage(),
			'link'  => empty($link) ? '/'.$this->controller->here.'?page=' : $link
		));
		$this->controller->load->helper('pagination');
	}
}
?>